package hello;

import java.util.Arrays;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ApplicationContext;

import com.sirap.basic.tool.C;
import com.sirap.basic.tool.D;
import com.sirap.basic.util.ThreadUtil;

@SpringBootApplication
//@Import(CacheLord.class)
public class GasApplication extends SpringBootServletInitializer {

	{
		Runtime.getRuntime().addShutdownHook(new Thread(){
			@Override
			public void run() {
				D.sink("Jamie");
			}
		});
	}
	
    public static void main(String[] args) {
        D.ts("Let's inspect the beans provided by Spring Boot:");
//    	System.exit(0);
        ApplicationContext lord = SpringApplication.run(GasApplication.class, args);
        lord.getBean(WebConfig.class).show();
        lord.getBean(DataSourceProperties.class).show();
        //D.sink(lord.getBean(CacheLord.class));
        D.ts("Let's inspect the beans provided by Spring Boot:");
//        D.pl(Konstants.MAP_DB_TYPE_CLASS);
        String[] beanNames = lord.getBeanDefinitionNames();
        D.sink(beanNames.length);
        C.listSome(Arrays.asList(beanNames), 2);
//        Arrays.sort(beanNames);
//        D.pl(beanNames.length);
//        ThreadUtil.sleepInSeconds(3);
//        System.exit(0);
    }
    
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    	return builder.sources(GasApplication.class);
    }
}
